package conf

import (
	"fmt"
	"time"
)

type Jwt struct {
	JwtSecret  string `yaml:"jwt_secret"`
	Issuer     string `yaml:"issuer"`
	AccessExp  int    `yaml:"access_exp"`
	RefreshExp int    `yaml:"refresh_exp"`
}

func (j *Jwt) Init() {
	//转为分钟比较AccessExp大于RefreshExp直接panic
	if time.Duration(j.AccessExp)*time.Minute > time.Duration(j.RefreshExp)*time.Hour {
		panic(fmt.Sprintf("The Refresh Expiration time (%d)  should be greater than the Access Expiration time(%d).",
			j.RefreshExp, j.AccessExp))
	}
}
